#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include "gallop_api.h"

using namespace std;


//convert a soap format to a binary format
void test_Converter() {
	const int readLength = 100;
	const char* soapFileName = "/home/luo_group/data/snp_data/human/human18_sort/human18-chr21.random";
	const char* refFileName = "/home/luo_group/data/snp_data/human/hg18_ref/chr21.fa";
	const char* cleanFileName = "/lhome/mian/data/chr21.soap.random"; //filtered soap file
	const char* outFileName = "/lhome/mian/data/chr21.soap.bin"; //output bin file

	/*clean the soap file and output as a cleaned file*/
	Converter::cleanSoap(cleanFileName, soapFileName, refFileName, readLength);
	cout << "The cleaned soap file is stored in: " << cleanFileName << endl;

	/*convert from soap format to binary format with range partitioning*/
	const unsigned int refLength = (unsigned int)(250)*(unsigned int)(1000*1000);
	const unsigned int winSize = 256*1024;
	const unsigned int bucketSize = 100;
	Converter* converter = new Converter(cleanFileName, readLength);
	converter->run(outFileName, refLength, winSize, bucketSize);
	delete converter;

}

void test_gsnp(int argc, char** argv) {
	gsnp(argc, argv);
}

void test_getMismatch() {
	const char* str = "G->99A20";
	unsigned char offset = 0;
	signed char sub = 0;
	Converter::getMismatch(str, &offset, &sub);

	cout << str << endl;
	printf("offset = %d\n", offset);
	cout << "sub = " << sub << endl;
}

int main(int argc, char** argv) {
	//test_getMismatch();
	//test_Converter();
	//test_gsnp(argc, argv);

	compareSoapBin_api(argc, argv);


	return EXIT_SUCCESS;
}


